﻿using Android.Bluetooth;

namespace SnakeRemote.Services.BluetoothService
{
    public sealed class BluetoothConnection : IDisposable
    {
        private readonly BluetoothSocket socket;
        public BluetoothConnection(BluetoothSocket socket)
        {
            this.socket = socket;
        }
        public IBluetoothDeviceInfo Device => new BluetoothDeviceInfo(socket.RemoteDevice);
        public Stream InputStream => socket.InputStream;
        public Stream OutputStream => socket.OutputStream;
        
        public bool IsConnected => socket.IsConnected;
        public void Connect()
        {
            socket.Connect();
        }
        public async Task ConnectAsync()
        {
            await socket.ConnectAsync();
        }

        public void Dispose()
        {
            socket.Close();
        }
    }
}
